<?php

defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'getlist';
$return=array();
$uniacid = $_SESSION['uniacid'];
$mid = $_SESSION['uid'];
$return['setting']=$basic=$this->plugin_setting('basic');
$return['basic']=$basic;
if($_RQ['op']=='getlist'){
	/*******main*******/
	//前端传回的状态
	$params=array('uniacid'=>$_SESSION['uniacid'],'headsid'=>$_SESSION['uid']);
	$params['status']=intval($_RQ['status']);
	$return['status']=intval($_RQ['status']);
	//我的团
	//先查询我的订单
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$teams=pdo_getslice('jy_aligroup_groups_team',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($teams){
		foreach($teams as &$item){
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['goods']=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['goodsid']));
			$item['groups']=pdo_get('jy_aligroup_groups',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['groupid']));
			if($item['groups']['agio']>0){
				$item['goods']['groupsprice']=$item['goods']['price']*$item['groups']['agio']/100;
			}else{
				$item['goods']['groupsprice']=$item['goods']['price'];
			}
			$item['amount']=$item['goods']['groupsprice']+$item['freight'];
			$item['order']=pdo_get('jy_aligroup_groups_order',array('uniacid'=>$_SESSION['uniacid'],'teamid'=>$item['id'],'mid'=>$item['headsid']));
		}
	}
	$return['list']=$teams;
	$return['params']=array('status'=>0);
	exi($return);
}

